﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NOPIDemo
{
    public partial class robotwhite : Form
    {
        public robotwhite()
        {
            InitializeComponent();
        }
        public string MD5(string str)
        {
            using (var md5 = System.Security.Cryptography.MD5.Create())
            {
                var b = Encoding.UTF8.GetBytes(str);
                b = md5.ComputeHash(b, 0, b.Length);
                StringBuilder sb = new StringBuilder(32);
                for (int i = 0; i < b.Length; i++)
                {
                    sb.Append(b[i].ToString("x2"));
                }
                return sb.ToString();
            }

        }
        private void button1_Click(object sender, EventArgs e)
        {
            Class1 c = new Class1();
            var dt = c.ExcelToDataTable(this.textBox1.Text, null, false);

            using (var stream = File.OpenWrite(this.textBox2.Text))
            {
                using (var sw = new StreamWriter(stream))
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        sw.WriteLine(String.Format("update RobotWhiteFilterConfig set GameAccount='{0}' where Id='{1}'", MD5(item[1].ToString()).ToUpper(), item[0].ToString()));
                    }
                }
            }
            MessageBox.Show("完事了");
        }
    }
}
